import type {
  IssueReceiptRecordsForm,
  IssueReceiptRecordsQuery,
  IssueReceiptRecordsVO,
} from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询出入库记录列表
 * @param params
 * @returns 出入库记录列表
 */
export function issueReceiptRecordsList(params?: IssueReceiptRecordsQuery) {
  return requestClient.get<PageResult<IssueReceiptRecordsVO>>(
    '/hm/issueReceiptRecords/list',
    { params },
  );
}

/**
 * 导出出入库记录列表
 * @param params
 * @returns 出入库记录列表
 */
export function issueReceiptRecordsExport(params?: IssueReceiptRecordsQuery) {
  return commonExport('/hm/issueReceiptRecords/export', params ?? {});
}

/**
 * 查询出入库记录详情
 * @param recordId id
 * @returns 出入库记录详情
 */
export function issueReceiptRecordsInfo(recordId: ID) {
  return requestClient.get<IssueReceiptRecordsVO>(
    `/hm/issueReceiptRecords/${recordId}`,
  );
}

/**
 * 新增出入库记录
 * @param data
 * @returns void
 */
export function issueReceiptRecordsAdd(data: IssueReceiptRecordsForm) {
  return requestClient.postWithMsg<void>('/hm/issueReceiptRecords', data);
}

/**
 * 更新出入库记录
 * @param data
 * @returns void
 */
export function issueReceiptRecordsUpdate(data: IssueReceiptRecordsForm) {
  return requestClient.putWithMsg<void>('/hm/issueReceiptRecords', data);
}

/**
 * 删除出入库记录
 * @param recordId id
 * @returns void
 */
export function issueReceiptRecordsRemove(recordId: ID | IDS) {
  return requestClient.deleteWithMsg<void>(
    `/hm/issueReceiptRecords/${recordId}`,
  );
}
